package com.wanho.java157.ProductManagement.service.Impl;

import com.wanho.java157.ProductManagement.mapper.OrdersMapper;
import com.wanho.java157.ProductManagement.po.Orders;
import com.wanho.java157.ProductManagement.service.OrdersService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrdersServiceImpl implements OrdersService {
    @Autowired
    private OrdersMapper ordersMapper;
    @Override
    public List<Orders> selectByStatus(@Param("STATUS")String status) {
        if(status==null){status="";}
        return ordersMapper.selectByStatus(status);
    }

    @Override
    public boolean modifyStatusById(String status, Integer id) {
        return ordersMapper.modifyStatusById(status,id);
    }

    @Override
    public Orders selectById(Integer id) {
        return ordersMapper.selectById(id);
    }

    @Override
    public List<Orders> selectOrderByEmployee() {
        return ordersMapper.selectOrderByEmployee();
    }

    @Override
    public List<Orders> selectOrderByCustomer() {
        return ordersMapper.selectOrderByCustomer();
    }

    @Override
    public List<Orders> selectOrder(String field) {
        if(field==null){
            return ordersMapper.selectByStatus("");}
        if(field.equals("2")){
            return ordersMapper.selectOrderByEmployee();
        }
        if(field.equals("3")){
            return ordersMapper.selectOrderByCustomer();
        }  return ordersMapper.selectByStatus("");
    }

    @Override
    public boolean addSales(Orders orders) {
        return ordersMapper.addSales(orders);
    }


}
